//1.引入样式表
//公用样式 
require('../../assets/css/index.less');
require('../../assets/fonts/iconfont.css');
// weui
require("../../lib/weui/weui.css")
let weui = require("../../lib/weui/weui.js")
// 当前页面样式
require('./courseDetails.less')

//2.引入工具函数 utils
const dom = require('../../utils/dom');
const https = require('../../utils/https');
const local = require('../../utils/local');


dom.ready(function () {
    // dom.tMenu("courseDetails");

    // dom.bMenu('sport');

    let id = location.search;
    console.log(id);


    function getCourseDetails() {
        https.get(`/api/train/courseDetail${id}`, function (res) {
            // console.log(res);
            if(res.errno==0){
                // console.log(res.data);
                dom.getEle('#courseBtn').setAttribute('data-id',res.data.courseId);
                local.set('videoS',res.data.fragments)
            }
        })
    }

    getCourseDetails();

    Jump('#courseBtn')

    Jump("#vidBox")


    function Jump(obj){
        dom.addEvent(obj,function(e){
            let id=e.target.dataset['id'];
            location.href='player.html?id='+id;
        })
    }

    function getUserInfo(){
        https.get("/api/user/info",res=>{
            let {errno,data}=res
            console.log(data);
            if(errno==0){
                // dom.getEle("#imgBtn").src=' http://fitness.h5.itsource.cn:3701' + data.imgUrl;
                dom.getEle("#nickname").textContent=data.nickName;
                dom.getEle("#intro").textContent=data.sign;
                local.set("userData",data);
            }
        })
    }
    getUserInfo()
})


